/*********************************************************************
 *
 *  elksip - a multi-platform Sip Phone Server
 *
 *  file: sip_debug.c  debug & log
 *
 *  Copyright 2011-2013 Elksip.
 *
 ********************************************************************/

#include <stdarg.h>

#include "sip_inc.h"

#include "sip_debug.h"

static int g_level =LOG_INFO;
static FILE *g_log_file=0;
/*
void elk_log(int level, char *msg)
{
    if(level < g_level)
    {
        fprintf(g_log_file, "%s\n", msg);
        fflush(g_log_file);
    }
}
*/
void elk_log(int level, const char *format, ... )
{
    if(level>g_level)
        return;
    va_list va;
    va_start(va, format);
    vfprintf(g_log_file, format, va);
    va_end(va);
    fprintf(g_log_file, "\n");
    fflush(g_log_file);
}
void elk_log_init()
{
    g_log_file=fopen("elksip.log","w");
}
void elk_log_close()
{
    if(g_log_file!=0)
        fclose(g_log_file);
}
